package com.example.pei.ithinklearnt.adapter;

import android.content.Context;

import com.example.pei.ithinklearnt.R;
import com.example.pei.ithinklearnt.adapter.base.BaseRecyclerAdapter;
import com.example.pei.ithinklearnt.adapter.base.BaseRecyclerHolder;
import com.example.pei.ithinklearnt.db.NewComment;
import com.example.pei.ithinklearnt.view.base.IMutlipleItem;

import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.Date;

import static com.example.pei.ithinklearnt.utils.MyUtils.getSendTime;

/**
 * 新评论通知列表
 * Created by Pei on 2018/4/21.
 */

public class NewCommentAdapter extends BaseRecyclerAdapter<NewComment> {

    public NewCommentAdapter(Context context, IMutlipleItem<NewComment> items, Collection<NewComment> datas) {
        super(context, items, datas);
    }

    @Override
    public void bindView(BaseRecyclerHolder holder, NewComment item, int position) {

        //设置 用户名
        holder.setText(R.id.tv_sendname,item.getFromUsername());
        //设置回复者头像
        holder.setImageView(item.getAvactor(), R.drawable.default_head, R.id.img_roudhead);
        //设置回复的内容
        holder.setText(R.id.comment,item.getContent());
        //设置原本的内容
        holder.setText(R.id.tv_bcontent,item.getbContent());
        //设置回复的时间
        Date data=new Date(item.getTime());
        String s=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(data);
        holder.setText(R.id.tv_sendtime,getSendTime(s));

    }
}
